package com.ghck.shop.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter;

import com.ghck.shop.service.GoodsService;
import com.ghck.shop.service.OperateService;
import com.ghck.shop.service.OrderService;
import com.ghck.shop.service.SellerService;
import com.ghck.shop.service.ShoppingCartService;
import com.ghck.shop.service.StatisticsService;
import com.ghck.shop.service.UserAddressService;



@Configuration
public class RpcConfig {
	
	@Autowired
	private GoodsService goodsService;
	
	@Autowired
	private UserAddressService userAddressService;
	
	@Autowired
	private OrderService orderService;
	
	@Autowired
	private SellerService sellerService;
	
	@Autowired
	private OperateService operateService;
	
	@Autowired
	private StatisticsService statisticsService;
	
	@Autowired
	private ShoppingCartService shoppingCartService;
	
	@Bean(name="/shoppingCartServiceRpcBean")
	public HttpInvokerServiceExporter shoppingCartServiceRpcBean(){
		HttpInvokerServiceExporter exporter = new HttpInvokerServiceExporter();
		exporter.setServiceInterface(ShoppingCartService.class);
		exporter.setService(shoppingCartService);
		return exporter;
	}
	
	@Bean(name="/statisticsServiceRpcBean")
	public HttpInvokerServiceExporter statisticsServiceRpcBean(){
		HttpInvokerServiceExporter exporter = new HttpInvokerServiceExporter();
		exporter.setServiceInterface(StatisticsService.class);
		exporter.setService(statisticsService);
		return exporter;
	}
	
	@Bean(name="/operateServiceRpcBean")
	public HttpInvokerServiceExporter operateServiceRpcBean(){
		HttpInvokerServiceExporter exporter = new HttpInvokerServiceExporter();
		exporter.setServiceInterface(OperateService.class);
		exporter.setService(operateService);
		return exporter;
	}
	
	@Bean(name="/sellerServiceRpcBean")
	public HttpInvokerServiceExporter sellerServiceRpcBean(){
		HttpInvokerServiceExporter exporter = new HttpInvokerServiceExporter();
		exporter.setServiceInterface(SellerService.class);
		exporter.setService(sellerService);
		return exporter;
	}
	
	
	
	@Bean(name="/goodsServiceRpcBean")
	public HttpInvokerServiceExporter goodsServiceRpcBean(){
		HttpInvokerServiceExporter exporter = new HttpInvokerServiceExporter();
		exporter.setServiceInterface(GoodsService.class);
		exporter.setService(goodsService);
		return exporter;
	}
	
	@Bean(name="/userAddressServiceRpcBean")
	public HttpInvokerServiceExporter userAddressServiceRpcBean(){
		HttpInvokerServiceExporter exporter = new HttpInvokerServiceExporter();
		exporter.setServiceInterface(UserAddressService.class);
		exporter.setService(userAddressService);
		return exporter;
	}
	
	@Bean(name="/orderServiceRpcBean")
	public HttpInvokerServiceExporter orderServiceRpcBean(){
		HttpInvokerServiceExporter exporter = new HttpInvokerServiceExporter();
		exporter.setServiceInterface(OrderService.class);
		exporter.setService(orderService);
		return exporter;
	}
}